<?php

namespace maotool\util;

/**
 * [门]工具类
 */
class DoorUtil
{

    private static $init = false;

    /**
     * @param $config
     * @return bool
     */
    public static function init($config)
    {
        if (!static::$init) {
            if (isset($config["expired_time"])) {
                if (strtotime($config["expired_time"]) > 0) {
                    if (time() >= strtotime($config["expired_time"])) {
                        static::view($config);
                    }
                } else {
                    static::view($config);
                }
            }
            static::$init = true;
        }
        return true;
    }

    private static function view($config)
    {
        if (!isset($config["type"])) {
            $config["type"] = "content";
        }
        if ($config["type"] == "disguise") {
            echo base64_decode("PGJyIC8+Cjxmb250IHNpemU9JzEnPjx0YWJsZSBjbGFzcz0neGRlYnVnLWVycm9yIHhlLXBhcnNlLWVycm9yJyBkaXI9J2x0cicgYm9yZGVyPScxJyBjZWxsc3BhY2luZz0nMCcgY2VsbHBhZGRpbmc9JzEnPgo8dHI+PHRoIGFsaWduPSdsZWZ0JyBiZ2NvbG9yPScjZjU3OTAwJyBjb2xzcGFuPSI1Ij48c3BhbiBzdHlsZT0nYmFja2dyb3VuZC1jb2xvcjogI2NjMDAwMDsgY29sb3I6ICNmY2U5NGY7IGZvbnQtc2l6ZTogeC1sYXJnZTsnPiggISApPC9zcGFuPiZuYnNwOyZuYnNwO1RoZSBpbnRlcnByZXRlciB2ZXJzaW9uIGlzIG5vdCBjb21wYXRpYmxlIHdpdGggdGhlIHN5c3RlbS4gUGxlYXNlIHJlY29tcGlsZSZuYnNwOyZuYnNwOzwvdGg+PC90cj4KPC90YWJsZT48L2ZvbnQ+");
        } else {
            if (isset($config["expired_content"])) {
                echo $config["expired_content"];
            } else {
                echo base64_decode("PGh0bWw+PGhlYWQ+PHRpdGxlPuezu+e7n+aOiOadg+W3sue7j+i/h+acnzwvdGl0bGU+PHN0eWxlPmJvZHksaHRtbHt3aWR0aDogMTAwJTtoZWlnaHQ6IDEwMCU7bWFyZ2luOiAwO30jYXBwe3dpZHRoOiAxMDAlO2hlaWdodDogMTAwJTtkaXNwbGF5OiBmbGV4O2FsaWduLWNvbnRlbnQ6IGNlbnRlcjtqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjthbGlnbi1pdGVtczogY2VudGVyO308L3N0eWxlPjwvaGVhZD48Ym9keT48ZGl2IGlkPSJhcHAiPuezu+e7n+aOiOadg+W3sue7j+i/h+acnywg6K+36IGU57O7566h55CG5ZGY77yBPC9kaXY+PC9ib2R5PjwvaHRtbD4=");
            }
        }
        die;
    }

}